#include "GateRPCHandler.h"
#include "boost/bind.hpp"
#include "DispatchHandler.h"
#include "GateServer.h"

#include "RPC_dispatch.pb.h"

void GateRpcHandler::init()
{
	regRpcHandler("sendClient", boost::bind(&GateRpcHandler::remote_sendClient, this, _1));
}

google::protobuf::Message* GateRpcHandler::remote_sendClient(const string& params)
{
	RPC_SendClient proto;

	__TRY__
		proto.ParseFromString(params);

		int net = proto.net_id();

		JME_Message msg(proto.msg_id(), net, proto.params());
		GateServer::getInstance()->sendClientMsg(net, msg);
	__CATCH_STD_EXCEPT_ERROR__
	
		LOGE("Parse protobuf error ==> [ %s ]", e.what());

	__TRY_END__
	
	return nullptr;
}
